#!/bin/sh

cd  ./afw-root/
read -p "请输入将要升级版本: " v1
echo "升级版本... $v1"
mvn versions:set -DnewVersion=${v1} -DgenerateBackupPoms=false
if [ $? -eq 0 ]; then
    compileSuccessFlag=1
    echo "版本升级成功  $v1"

    read -p "是否clean & install jar 包 yes/no? " v2
    if [ "yes" == ${v2}  ]; then
        echo " 执行中 .....  mvn clean install -Dmaven.test.skip=true "
        mvn clean install -Dmaven.test.skip=true
        if [ $? -eq 0 ]; then
             echo "install 成功 "
             read -p "是否 deploy jar包到仓库  yes/no? " v3
              if [ "yes" == ${v3}  ]; then
                mvn deploy
              else
                echo "请手动 deploy jar包 "
              fi
        fi
    else
     echo "请自己 mvn clean install -Dmaven.test.skip=true "
    fi


    read -p "是否要直接 push代码到远程仓库 yes/no? " v4
    if [ "yes" == ${v4}  ]; then
        cd ../
        echo " 提交 and PUSH "
        git pull origin
        git add .
        git commit -m "Afw 框架 升级版本 $v1"
        git push origin
        if [ $? -eq 0 ]; then
             echo "push 成功 "
        fi
    else
     echo "请手动 push 代码"
    fi
else
    echo "升级失败"
fi

